package p270jp.pxv.android.activity;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.databinding.DataBindingUtil;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import p014ae.AbstractActivityC0097j4;
import p270jp.pxv.android.R;
import p307l9.EdgeTreatment;
import p314lg.ActivityWebview2Binding;

/* renamed from: jp.pxv.android.activity.WebViewActivity2 */
/* loaded from: classes2.dex */
public class WebViewActivity2 extends AbstractActivityC0097j4 {

    /* renamed from: v */
    public ActivityWebview2Binding f18749v;

    /* renamed from: jp.pxv.android.activity.WebViewActivity2$a */
    /* loaded from: classes2.dex */
    public class C4145a extends WebViewClient {

        /* renamed from: a */
        public final /* synthetic */ Map f18750a;

        public C4145a(Map map) {
            WebViewActivity2.this = r1;
            this.f18750a = map;
        }

        /* renamed from: a */
        public final boolean m4681a(Uri uri) {
            String scheme = uri.getScheme();
            if (scheme.equals("http") || scheme.equals("https")) {
                WebViewActivity2.this.f18749v.f21605r.loadUrl(uri.toString(), this.f18750a);
                return false;
            }
            WebViewActivity2.this.f18749v.f21605r.getContext().startActivity(new Intent("android.intent.action.VIEW", uri));
            return true;
        }

        @Override // android.webkit.WebViewClient
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            return m4681a(Uri.parse(str));
        }

        @Override // android.webkit.WebViewClient
        @TargetApi(24)
        public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
            return m4681a(webResourceRequest.getUrl());
        }
    }

    /* renamed from: S0 */
    public static Intent m4682S0(Context context, String str, String str2, boolean z) {
        EdgeTreatment.m3909i(context);
        EdgeTreatment.m3909i(str);
        Intent intent = new Intent(context, WebViewActivity2.class);
        intent.putExtra("URL", str);
        intent.putExtra("REFERER", str2);
        intent.putExtra("ENABLE_ZOOM", z);
        return intent;
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onBackPressed() {
        if (this.f18749v.f21605r.canGoBack()) {
            this.f18749v.f21605r.goBack();
        } else {
            this.f940i.m12030b();
        }
    }

    @Override // androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ActivityWebview2Binding g2Var = (ActivityWebview2Binding) DataBindingUtil.m11369d(this, R.layout.activity_webview2);
        this.f18749v = g2Var;
        g2Var.f21604q.setFitsSystemWindows(true);
        m7042R0(this.f18749v.f21604q);
        m7044P0().mo6936o(true);
        m7044P0().mo6929v("pixiv");
        HashMap hashMap = new HashMap();
        hashMap.put("Accept-Language", Locale.getDefault().toString());
        String stringExtra = getIntent().getStringExtra("REFERER");
        if (stringExtra != null) {
            hashMap.put("Referer", stringExtra);
        }
        this.f18749v.f21605r.setWebViewClient(new C4145a(hashMap));
        String stringExtra2 = getIntent().getStringExtra("URL");
        this.f18749v.f21605r.getSettings().setJavaScriptEnabled(true);
        if (getIntent().getBooleanExtra("ENABLE_ZOOM", false)) {
            this.f18749v.f21605r.getSettings().setBuiltInZoomControls(true);
        }
        this.f18749v.f21605r.loadUrl(stringExtra2, hashMap);
    }

    @Override // p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        this.f18749v.f21605r.stopLoading();
        super.onDestroy();
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        onBackPressed();
        return true;
    }
}
